


txt_file1 = open('../../data/txt/roi/result_roi.txt')
all_data_in_txt1 = ''
data_list_in_txt1 = ''
all_data_in_txt1 = txt_file1.read()
data_list_in_txt1 = all_data_in_txt1.split("\n")

txt_file2 = open('../../data/txt/roi/test3.txt')
all_data_in_txt2 = ''
data_list_in_txt2 = ''
all_data_in_txt2 = txt_file2.read()
data_list_in_txt2 = all_data_in_txt2.split("\n")

all_seperate_data = []

number = len(data_list_in_txt2)

for i in range(number):
    seperate_data1 = data_list_in_txt1[i].split(",")
    seperate_data2 = data_list_in_txt2[i]
    # 因为原来代码只有x,y的坐标，所以a应该只有两个值的情况才对
    # 但生成的txt文件因为带有图片名称，所以有三个值的情况出现
    if len(seperate_data1) != 2 and len(seperate_data1) != 3:
        continue
        # 因为第三列是图片名称，这里用不到
    seperate_data1 = [int(i) for i in seperate_data1[:2]]

    seperate_data1.append(seperate_data2)

    all_seperate_data.append(seperate_data1)

# txt_file = open('../../data/txt/roi/result_roi2.txt', 'w')
# result_num = len(all_seperate_data)
# for i in range(result_num):
#     txt_file.write(str(all_seperate_data[i][0]) + ',' + str(all_seperate_data[i][1]) + ',' + str(all_seperate_data[i][2]) + '\n')
# txt_file.close()

txt_file = open('../../data/txt/roi/recognized_roi.txt', 'w')
result_num = len(all_seperate_data)
for i in range(result_num):
    if float(all_seperate_data[i][2]) >= 0.99999:
        txt_file.write(str(all_seperate_data[i][0]) + ',' + str(all_seperate_data[i][1]) + '\n')
txt_file.close()